package com.musifind.utils;

import java.io.ByteArrayOutputStream;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;

public class ImageUtils {
	public static byte[] getByteArray(Bitmap bitmap) {
		if (bitmap == null)
			return null;
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		bitmap.compress(CompressFormat.PNG, 0, bos);
		return bos.toByteArray();
	}

	public static Bitmap getBitmap(byte[] bitmap) {
		if (bitmap == null)
			return null;
		return BitmapFactory.decodeByteArray(bitmap, 0, bitmap.length);
	}
}
